#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :km.py
# @Time      :2024/11/8 8:58
# @Author    :Darcy
# @Desc      :

from django.conf import settings
import django

DEBUG = False
settings.configure(
    DATABASES={
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2',
            'NAME': 'dn_name',
            'USER': 'user',
            'PASSWORD': 'password',
            'HOST': '0.0.0.0',
            'PORT': '5432',
            "CONN_MAX_AGE": 60,  # 60秒
        },
    },
    INSTALLED_APPS=('models',)  # 这个是必须要指定的，models文件在biz目录下，这个install app就写biz

)  # 设置数据库信息，和django的settings中一样的
django.setup()

from models.models import *


def func_1(phone):
    lis = ['name', 'gender', 'remark_mobiles', 'corp_name', 'add_time']
    if phone:
        objs = BackUserContactInfoTable.objects. \
            filter(deleted_time=None, phone__contains=phone).values(*lis)
    else:
        objs = BackUserContactInfoTable.objects.filter(deleted_time=None).values(*lis)
    for obj in objs:
        obj['add_time'] = obj['add_time'].strftime('%Y-%m-%d %H:%M:%S')
    return list(objs)

# if __name__ == '__main__':
#     print(func_1(''))
